/** * Sets the priority attribute on a menu element, determining its position in the menu. * Lower priority elements appear on the left, higher priority on the right. */ export function setElementPriority(button: HTMLElement, priority: number) { button.setAttribute("priority", String(priority)); } /** * Gets the priority attribute from a menu element. * @returns The priority value, or undefined if not set or not a valid number. */ export function getElementPriority(button: HTMLElement): number | undefined { const priority = button.getAttribute("priority"); if (priority) { const val = Number.parseFloat(priority); if (!Number.isNaN(val)) return val; } return undefined; }